/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NewGame.java
 *
 * Created on Jan 8, 2012, 1:07:24 PM
 */
package views.panes;

import controller.GameSettings;
import javax.swing.JPanel;
import views.MafiaFrame;

/**
 *
 * @author darkdev
 */
public class NewGame extends javax.swing.JPanel {

    MafiaFrame gui;
    JPanel cancelPanel;
    /** Creates new form NewGame */
    public NewGame(MafiaFrame gui, JPanel cancelPanel){
        initComponents();
        this.gui = gui;
        this.cancelPanel = cancelPanel;
        gui.setGameSettings(new GameSettings());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        Default = new javax.swing.JButton();
        Custom = new javax.swing.JButton();
        Configure = new javax.swing.JButton();
        back = new javax.swing.JButton();

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText(" Create a New Game");

        Default.setText("Default Game");
        Default.setToolTipText("The game will start with all the default roles: citizen, killer, detective, handicapper, doctor");
        Default.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                DefaultMouseClicked(evt);
            }
        });
        Default.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DefaultActionPerformed(evt);
            }
        });

        Custom.setText("Custom Game");
        Custom.setToolTipText("Define the roles to be played and the number of players per role");
        Custom.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CustomMouseClicked(evt);
            }
        });

        Configure.setText("Configure Game");
        Configure.setToolTipText("Configure Game Parametters");
        Configure.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ConfigureMouseClicked(evt);
            }
        });
        Configure.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConfigureActionPerformed(evt);
            }
        });

        back.setText("Back ");
        back.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                backMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(Configure)
                            .addComponent(Default)
                            .addComponent(Custom)
                            .addComponent(back)))
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {Configure, Custom, Default, back});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(Configure)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Default)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Custom)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(back)
                .addContainerGap(102, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {Configure, Custom, Default, back});

    }// </editor-fold>//GEN-END:initComponents

    private void DefaultActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DefaultActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_DefaultActionPerformed

    private void ConfigureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConfigureActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ConfigureActionPerformed

    private void ConfigureMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ConfigureMouseClicked
        // TODO add your handling code here:
        gui.update(new ConfigurationPane(gui,this));
    }//GEN-LAST:event_ConfigureMouseClicked

    private void backMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_backMouseClicked
        // TODO add your handling code here:
        gui.update(cancelPanel);
    }//GEN-LAST:event_backMouseClicked

    private void CustomMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CustomMouseClicked
        // TODO add your handling code here:
        gui.update(new CustomGamePane(gui,this));
    }//GEN-LAST:event_CustomMouseClicked

    private void DefaultMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_DefaultMouseClicked
        // TODO add your handling code here:     
       gui.setDefaultRoles();        
               
       gui.update(new PlayersRegistrationPane(gui,this));
    }//GEN-LAST:event_DefaultMouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Configure;
    private javax.swing.JButton Custom;
    private javax.swing.JButton Default;
    private javax.swing.JButton back;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables
}
